package com.cool.modules.erp.controller.admin;

import cn.hutool.json.JSONObject;
import com.cool.core.annotation.CoolRestController;
import com.cool.core.base.BaseController;
import com.cool.core.request.R;
import com.cool.modules.erp.entity.ErpSupplierInfoEntity;
import com.cool.modules.erp.service.ErpSupplierInfoService;
import com.mybatisflex.core.query.QueryWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;

import static com.cool.core.enums.QueryModeEnum.ENTITY_WITH_RELATIONS;
import static com.cool.modules.erp.entity.table.ErpSupplierInfoEntityTableDef.ERP_SUPPLIER_INFO_ENTITY;

/**
 * 供应商信息
 */
@Tag(name = "供应商信息", description = "供应商信息")
@CoolRestController(api = {"add", "delete", "update", "page", "list", "info"})
public class AdminErpSupplierInfoController extends BaseController<ErpSupplierInfoService, ErpSupplierInfoEntity> {
    @Override
    protected void init(HttpServletRequest request, JSONObject requestParams) {
        setPageOption(createOp()
                .keyWordLikeFields(ERP_SUPPLIER_INFO_ENTITY.NAME,ERP_SUPPLIER_INFO_ENTITY.CODE,
                        ERP_SUPPLIER_INFO_ENTITY.SIMPLE_NAME)
                .queryModeEnum(ENTITY_WITH_RELATIONS)
                .queryWrapper(QueryWrapper.create().eq(ERP_SUPPLIER_INFO_ENTITY.ENABLE.getName(), 1))
        );
        setListOption(createOp().queryWrapper(QueryWrapper.create().eq(ERP_SUPPLIER_INFO_ENTITY.ENABLE.getName(), 1)));
    }

}